﻿Public Class Radicionales

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eadicionales)
        Dim adicionales As List(Of Eadicionales) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                adicionales = Dadicionales.SeleccionarTodo(descEmpresa)
                If adicionales Is Nothing Then adicionales = New List(Of Eadicionales)
                If DisplaySelect Then adicionales.Insert(0, New Eadicionales("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return adicionales
    End Function
    Public Shared Function SeleccionarCasa(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32) As List(Of Eadicionales)
        Dim adicionales As List(Of Eadicionales) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                adicionales = Dadicionales.SeleccionarCasa(descEmpresa, idProyecto)
                If adicionales Is Nothing Then adicionales = New List(Of Eadicionales)
                If DisplaySelect Then adicionales.Insert(0, New Eadicionales("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return adicionales
    End Function
    Public Shared Function SeleccionarAdicionales(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32) As List(Of Eadicionales)
        Dim adicionales As List(Of Eadicionales) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                adicionales = Dadicionales.SeleccionarAdicionales(descEmpresa, idProyecto)
                If adicionales Is Nothing Then adicionales = New List(Of Eadicionales)
                If DisplaySelect Then adicionales.Insert(0, New Eadicionales("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return adicionales
    End Function
    Public Shared Function SeleccionarTipo(ByVal descEmpresa As String, ByVal idAdicional As Int32) As String
        Dim adicionales As String = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                adicionales = Dadicionales.SeleccionarTipo(descEmpresa, idAdicional)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return adicionales
    End Function
    Public Shared Function SeleccionarTodoxTipo(ByVal descEmpresa As String, ByVal tipoCasa As String, ByVal idAdicional As Int32) As List(Of Eadicionales)
        Dim adicionales As List(Of Eadicionales) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                adicionales = Dadicionales.SeleccionarTodoXTipo(descEmpresa, tipoCasa, idAdicional)
                If adicionales Is Nothing Then adicionales = New List(Of Eadicionales)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return adicionales
    End Function
    Public Shared Function SeleccionarTodoxIds(ByVal descEmpresa As String, ByVal ids As Int32) As Eadicionales
        Dim adicionales As Eadicionales = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                adicionales = Dadicionales.SeleccionarTodoXIds(descEmpresa, ids)
                'If adicionales Is Nothing Then adicionales = New List(Of Eadicionales)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return adicionales
    End Function

   
    Public Shared Function SeleccionarTodoXId(ByVal descEmpresa As String, ByVal pIdDscto As Int32) As Eadicionales
        Dim descuento As Eadicionales = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuento = Dadicionales.SeleccionarTodoXId(descEmpresa, pIdDscto)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuento
    End Function
    Public Shared Function SeleccionarTodoXIdProyecto(ByVal descEmpresa As String, ByVal pIdDscto As Int32, ByVal idProyecto As Int32) As Eadicionales
        Dim descuento As Eadicionales = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuento = Dadicionales.SeleccionarTodoXIdProyecto(descEmpresa, pIdDscto, idProyecto)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuento
    End Function
    Public Shared Function SeleccionarProyecto(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eproyecto)
        Dim proyectos As List(Of Eproyecto) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proyectos = Dadicionales.SeleccionarProyecto(descEmpresa)
                If proyectos Is Nothing Then proyectos = New List(Of Eproyecto)
                If DisplaySelect Then proyectos.Insert(0, New Eproyecto("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return proyectos
    End Function
   
    Public Shared Function SeleccionarTpoAdicional(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eadicionales)
        Dim tpoadicionales As List(Of Eadicionales) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                tpoadicionales = Dadicionales.SeleccionarTpoadicional(descEmpresa)
                If tpoadicionales Is Nothing Then tpoadicionales = New List(Of Eadicionales)
                If DisplaySelect Then tpoadicionales.Insert(0, New Eadicionales("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return tpoadicionales
    End Function

    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pDescuento As Eadicionales) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dadicionales.Añadir(descEmpresa, pDescuento)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pDescuento As Eadicionales) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dadicionales.Editar(descEmpresa, pDescuento)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pDescuento As Eadicionales) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dadicionales.Eliminar(descEmpresa, pDescuento)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function Buscar(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pDescuento As Eadicionales) As List(Of Eadicionales)
        Dim adicionales As List(Of Eadicionales) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                adicionales = Dadicionales.Buscar(descEmpresa, pDescuento)
                If adicionales Is Nothing Then adicionales = New List(Of Eadicionales)
                If DisplaySelect Then adicionales.Insert(0, New Eadicionales("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return adicionales
    End Function

End Class
